package com.ruoyi.web.controller.yijing;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yijing.domain.YjGua;
import com.ruoyi.yijing.service.IYjGuaiService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 卦基本信息Controller
 * 
 * @author ruoyi
 * @date 2024-01-22
 */
@RestController
@RequestMapping("/yijing/guai")
public class YjGuaiController extends BaseController
{
    @Autowired
    private IYjGuaiService yjGuaiService;

    /**
     * 查询卦基本信息列表
     */
    //@PreAuthorize("@ss.hasPermi('yijing:guai:list')")
    @GetMapping("/list")
    public TableDataInfo list(YjGua yjGuai)
    {
        startPage();
        List<YjGua> list = yjGuaiService.selectYjGuaiList(yjGuai);
        return getDataTable(list);
    }

    /**
     * 获取卦基本信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('yijing:guai:query')")
    @GetMapping(value = "/{guaiId}")
    public AjaxResult getInfo(@PathVariable("guaiId") Integer guaiId)
    {
        return success(yjGuaiService.selectYjGuaiByGuaiId(guaiId));
    }

    /**
     * 新增卦基本信息
     */
    //@PreAuthorize("@ss.hasPermi('yijing:guai:add')")
    @Log(title = "卦基本信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YjGua yjGuai)
    {
        return toAjax(yjGuaiService.insertYjGuai(yjGuai));
    }

    /**
     * 修改卦基本信息
     */
    //@PreAuthorize("@ss.hasPermi('yijing:guai:edit')")
    @Log(title = "卦基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YjGua yjGuai)
    {
        return toAjax(yjGuaiService.updateYjGuai(yjGuai));
    }


}
